const proxy = require('http-proxy-middleware');
module.exports = function (app) {

  switch (process.env.NODE_ENV) {
    case "production": {
      app.use(
        '/api',
        proxy({
          target: 'http://localhost',
          changeOrigin: true,
        })
      );
      app.use(
        '/',
        proxy({
          pathRewrite: {
            '^/': '/WordBase'
          },
        })
      );
      break;
    }
    case "development": {
      app.use(
        '/api',
        proxy({
          target: 'http://localhost:5678', //gateway socket
          changeOrigin: true,
          pathRewrite: {
            '^/api/': '/'
          },
        })
      );
      break;
    }
    default:
      break;
  }
};